package com.joysuch.wwyt.workflow.controller;


import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.core.common.util.PageDataUtils;
import com.joysuch.wwyt.workflow.bean.WorkFlowFormTemplateBean;
import com.joysuch.wwyt.workflow.bean.WorkFlowFormTemplateQueryBean;
import com.joysuch.wwyt.workflow.bean.WorkFlowFormTemplateTypeBean;
import com.joysuch.wwyt.workflow.entity.WorkFlowFormTemplate;
import com.joysuch.wwyt.workflow.entity.WorkFlowFormTemplateType;
import com.joysuch.wwyt.workflow.service.WorkFlowFormTemplateService;
import com.joysuch.wwyt.workflow.service.WorkFlowFormTemplateTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/workflow/form-temp-type")
@Api(tags = "业务流程文档引擎-表单模板类型管理")
@CrossOrigin
public class WorkFlowFormTemplateTypeController {

    @Autowired
    private WorkFlowFormTemplateTypeService formTemplateTypeService;



    @GetMapping("/list")
    @ApiOperation(value = "获取表单模板类型列表(树结构）" )
    public ResultBean list() {
       return ResultBean.success(formTemplateTypeService.listTree());
    }


    @GetMapping("/getById")
    @ApiOperation(value = "根据Id查询表单模板类型" , response = WorkFlowFormTemplateType.class)
    public ResultBean getById(@RequestParam Long id) {
        WorkFlowFormTemplateType flowFormTemplateType = formTemplateTypeService.findById(id);
        return ResultBean.success(flowFormTemplateType);
    }

    @RequiresPermissions("workflow:formTempType:delete")
    @GetMapping("/deleteById")
    @ApiOperation(value = "根据Id删除表单模板类型")
    public ResultBean deleteById(@RequestParam Long id) {
        return formTemplateTypeService.delete(id);

    }

    @RequiresPermissions("workflow:formTempType:save")
    @PostMapping("/save")
    @ApiOperation(value = "保存表单模板类型" , response = WorkFlowFormTemplateType.class)
    public ResultBean save(@RequestBody WorkFlowFormTemplateTypeBean bean) {
        return formTemplateTypeService.save(bean);
    }


}
